package com.ruoyi.patrol.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.patrol.domain.PtFormDetailsOption;
import com.ruoyi.patrol.service.IPtFormDetailsOptionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单问题答案Controller
 * 
 * @author lkm
 * @date 2022-11-12
 */
@RestController
@RequestMapping("/patrol/option")
public class PtFormDetailsOptionController extends BaseController
{
    @Autowired
    private IPtFormDetailsOptionService ptFormDetailsOptionService;

    /**
     * 查询单问题答案列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:option:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtFormDetailsOption ptFormDetailsOption)
    {
        startPage();
        List<PtFormDetailsOption> list = ptFormDetailsOptionService.selectPtFormDetailsOptionList(ptFormDetailsOption);
        return getDataTable(list);
    }

    /**
     * 导出单问题答案列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:option:export')")
    @Log(title = "单问题答案", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PtFormDetailsOption ptFormDetailsOption)
    {
        List<PtFormDetailsOption> list = ptFormDetailsOptionService.selectPtFormDetailsOptionList(ptFormDetailsOption);
        ExcelUtil<PtFormDetailsOption> util = new ExcelUtil<PtFormDetailsOption>(PtFormDetailsOption.class);
        return util.exportExcel(list, "option");
    }

    /**
     * 获取单问题答案详细信息
     */
    @PreAuthorize("@ss.hasPermi('patrol:option:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ptFormDetailsOptionService.selectPtFormDetailsOptionById(id));
    }

    /**
     * 修改单问题答案
     */
    @PreAuthorize("@ss.hasPermi('patrol:option:edit')")
    @Log(title = "单问题答案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtFormDetailsOption ptFormDetailsOption)
    {
        return toAjax(ptFormDetailsOptionService.updatePtFormDetailsOption(ptFormDetailsOption));
    }

    /**
     * 删除单问题答案
     */
    @PreAuthorize("@ss.hasPermi('patrol:option:remove')")
    @Log(title = "单问题答案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ptFormDetailsOptionService.deletePtFormDetailsOptionByIds(ids));
    }
}
